package cn.shadow.entity;

import cn.shadow.moulde.ISender;
import cn.shadow.proto.server.PlayerServerProtoContent.*;
import cn.shadow.utils.IDUtils;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用户类
 */
@Data
@NoArgsConstructor
public class User {
    /**
     * userId为平台id+区服id+自增id
     **/

    private long playerId;
    private long createTime;
    private String username;//用户名
    private Player player; //玩家对象

    public User(int id, int serverID, int operatorID, long createTime, String username) {
        this.createTime = createTime;
        this.username = username;
        this.playerId = IDUtils.combineUserAndServerAndOperatorID(id, serverID, operatorID);
    }

    public User(long playerId, long createTime, String username) {
        this.playerId = playerId;
        this.createTime = createTime;
        this.username = username;
    }

    public void decodePlayer(PlayerServerProto playerProto, ISender sender) {
        this.player = new Player(playerProto, sender);
    }
}
